package com.hngy.xpq.shoppingcartmodule.tool;

import android.util.ArrayMap;

import com.hngy.xpq.shoppingcartmodule.bean.Cart;

import java.util.List;
import java.util.Map;

public class alg {

    public static Map<String, Object> CountZPrice(List<Cart> list){
        Map<String, Object> map = new ArrayMap<>();
        int z_number = 0;   // 价格
        float z_price = 0;  // 数量
        float z = 0;
        for (int i = 0; i < list.size(); i++) {
            z_price += (list.get(i).getNumber() - 1) * list.get(i).getShop().getPrice() +
                    list.get(i).getShop().getPrice() * list.get(i).getShop().getDis()/10;
            z_number += list.get(i).getNumber();
            z += list.get(i).getNumber() * list.get(i).getShop().getPrice();
        }
        map.put("price", z_price);
        map.put("number", z_number);
        map.put("z", z);
        map.put("youhui", z - z_price);
        return map;
    }

}
